<template>
  <div class="app-container">
    <el-form :inline="true" ref="ruleForm" :model="formInline" class="demo-form-inline">
       <el-form-item label="账号" prop="target_account">
        <el-input v-model="formInline.target_account" placeholder="请输入账号" @keyup.enter.native="$emit('on-filter',formInline)"></el-input>
      </el-form-item>
      <el-form-item label="昵称" prop="target_nick">
        <el-input v-model="formInline.target_nick" placeholder="请输入昵称" @keyup.enter.native="$emit('on-filter',formInline)"></el-input>
      </el-form-item>
      <el-form-item label="会员类型" prop="target_type">
        <el-select v-model="formInline.target_type" placeholder="会员类型">
          <el-option
            v-for="item in typeList"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="禁言时长" prop="ttl">
        <el-select v-model="formInline.ttl" placeholder="禁言时长">
          <el-option
            v-for="item in timeList"
            :label="(item.value==0?'':item.value)+(item.unit==0?'永久':(item.unit==1?'分钟':(item.unit==2?'小时':(item.unit==3?'天':'全部'))))"
            :key="item.id"
            :value="item.ttl"

          ></el-option>
        </el-select>
      </el-form-item >
      <el-form-item label="禁言类别" prop="cate">
        <el-select v-model="formInline.cate" placeholder="禁言类别">
          <el-option
            v-for="item in cateList"
            :label="item.name"
            :key="item.value"
            :value="item.name"

          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="操作人" prop="account">
        <el-input v-model="formInline.account" placeholder="请输入" @keyup.enter.native="$emit('on-filter',formInline)"></el-input>
      </el-form-item>
      <el-form-item>
        <el-col>
          <el-form-item prop="time" class="data-item">
              <el-select  v-model="formInline.time_type">
                <el-option label="禁言开始时间" :value="1"></el-option>
                <el-option label="禁言结束时间" :value="2"></el-option>
              </el-select>
              <el-date-picker
              class="date-picker-box"
                v-model="formInline.time"
                type="datetimerange"
                align="right"
                unlink-panels
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                value-format="yyyy-MM-dd HH:mm:ss"
                :default-time="['00:00:00', '23:59:59']"
                :picker-options="pickerWeekStep" >
              </el-date-picker>
          </el-form-item>
        </el-col>
      </el-form-item>
      <!-- <el-form-item>
        <el-col>
          <el-form-item prop="time" label="禁言结束时间">
            <el-date-picker
              v-model="formInline.time"
              type="datetimerange"
              align="right"
              unlink-panels
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd HH:mm:ss"
              :default-time="['00:00:00', '23:59:59']"
              :picker-options="pickerWeekStep">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-form-item> -->
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="$emit('on-filter',formInline)">搜索
      </el-button>
      <el-button @click="selfResetForm('ruleForm')">重置</el-button>
    </el-form>
  </div>

</template>

<script>
import { form, grid, pickerOption } from '@/build';
import { getBannedTime, getcate } from '@/services/api/chatRoom';


export default {
  name: 'form-filter',
  mixins: [form, grid, pickerOption],
  data() {
    return {
      typeList: [
        { title: '全部', value: '' },
        { title: '本站会员', value: '0' },
        { title: '外部拉取', value: '1' },
      ],
      cateList: [], // 举报类别
      timeList: [],
      auditFirList: [],
      auditSecList: [],
      formInline: {
        time: [
          moment().format('YYYY-MM-DD 00:00:00'),
          moment().format('YYYY-MM-DD 23:59:59'),
        ],
        creator: undefined,
        firstApprover: undefined,
        secondApprover: undefined,
        account: '', // 账号
        target_nick: '',
        target_account: '',
        cate: '',
        ttl: '',
        time_type: 1,
        target_type: undefined, // 0 本站会员 1外部拉取
        page: 1,
        size: 20,
      },

    };
  },
  methods: {
    selfResetForm(formName) {
      this.resetForm(formName);
      this.$emit('on-filter', this.formInline);
    },
  },
  mounted() {
    this.bindGet(getBannedTime, 'timeList', {
      format: (data) => {
        data.unshift({
          id: undefined,
          name: '全部',
          value: '',
          unit: '全部',
          ttl: '',
        });
        return data;
      },
    });
    this.bindGet(getcate, 'cateList', {
      format: (data) => {
        data.unshift({
          id: undefined,
          name: '全部',
          value: undefined,
        });
        return data;
      },
    });
    this.getAll();
  },
};
</script>

<style lang="scss" scoped>
  .with-pre-select {
    .el-input-group__prepend {
      .el-select {
        width: 160px;
      }
    }
  }

  .money-range {
    .el-input {
      width: 100px;
    }
  }

</style>
<style>
.data-item .el-select{position: relative; left:5px;}
.data-item input.el-input__inner{border-top-right-radius: 0;border-bottom-right-radius: 0;background: #f5f7fa !important;color:#909399;border-right:none;width:130px}
.data-item  input.el-input__inner:focus{border-color:#dcdfe6 !important}
.data-item div.el-input__inner.el-date-editor{border-top-left-radius: 0 !important;border-bottom-left-radius: 0 !important;}
</style>
